<cfscript>    
    view = createObject("component", session.rootDir & ".views.layout");
    if( Session.Auth EQ True and (Session.strAuthType EQ Session.MANAGERS or Session.strAuthType EQ Session.IT or Session.strAuthType EQ Session.HR or Session.Manager) ){
		view.init("Step 2:  HR - Pre Orientation",
			"/jquery/ui-1.8.5/jquery-ui.min.js,/jquery/plugins/scrollTo/jquery.scrollTo-1.4.2-min.js, /" & session.rootDir & "/static/js/SCF/Step2-PreOrientation.js",
			"/jquery/ui-1.8.5/themes/cupertino/jquery-ui.css","Home",index);
    }else{
        view.init("Denied","","","Home","Denied");
    }    
    view.html();
</cfscript>

<cffunction name="index" access="public" output="true" returntype="any">
    <!--- if the employee to hire isn't specified, redirect to Step 2 - Page 1 --->
    <cfif not isdefined("URL.StepID")>
        <cflocation url="/#Session.RootDir#/status.cfm" addtoken="no">
    </cfif>
    <cfscript>
        import models.*;
        FormAction = '/' & Session.RootDir & '/controller/SubmitHandler.cfm?SCFStep2=update';
        FormDecline = '/' & Session.RootDir & '/controller/SubmitHandler.cfm?SCFStep2=update&Decline=1';
        KronosQueries = CreateObject("component", session.rootDir & ".DatabaseQueries.Kronos");
        CurrentEmployees = KronosQueries.funcGetCurrentEmployees();
        AccessControlQueries = CreateObject("component", session.rootDir & ".DatabaseQueries.AccessControl");
        JustinsJobProg = CreateObject("component", session.rootDir & ".DatabaseQueries.JustinsJobProg");
        StepAction = entityLoadByPK("StepActions", URL.StepID);
        Employee = entityLoadByPK("Employee", StepAction.getEmployeeID());
        Lunch = entityLoadByPK("Lunch", Employee.getLunchID());
        Shifts = entityload("Shift");
        GetReasonCodes = KronosQueries.funcGetReasonCodes('PP');
        GetSalaryHourly = KronosQueries.funcGetSalaryHourly('SH');
        GetWorkersCompInfo = KronosQueries.funcGetWorkersCompInfo();
        GetReasonCodes = KronosQueries.funcGetReasonCodes('PS');
        GetCompTypes = KronosQueries.funcGetCompTypes('CT');
        GetFrequency = KronosQueries.funcGetFrequency();
        GetDepts = KronosQueries.funcGetDepts();
        GetPositions = KronosQueries.funcGetPositions();
        GetEmpCodes = KronosQueries.funcGetEmpCodes();
        GetSupDept = KronosQueries.funcGetSupDept(Employee.getSupervisorID());
        GetJobPosting = JustinsJobProg.funcGetJobPostings(Employee.getPostingID());
        
        if(Employee.getPostingID() EQ -1){
            JobToHire = "Other - See Manager Comments";
        }else{
            JobToHire = "#GetJobPosting.JobTitle# (#GetJobPosting.Bulletin#)";
        }
        
    </cfscript>
    
    <cfoutput> 
    
        <h1 class="title">Step 2:  HR - Pre Orientation</h1>
        <div class="entry">
            Welcome, #Session.EmpInfo.FirstName# #Session.EmpInfo.LastName#.  
            On this page you'll be asked to review the information provided by the hiring manager, 
            and provide additional information you obtained during the negotion process.
            
            <cfform name="frmStep2" method="post" action="#FormAction#">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td>
                            <fieldset>
                                <legend>1) Information provided by the Hiring Manager:</legend>
                                <table>
                                    <tr>
                                        <td width = "10">&nbsp;</td>
                                        <td>Employee to Hire:</td>
                                        <td>
                                            <cfinput type="text" name="FirstName" error_message="Please provide a first name for the employee you'd like to hire." tabindex="5" value="#Employee.getFirstName()#">
                                            <cfinput type="text" name="MiddleName" size=1 maxlength="2" tabindex="7" value="#Employee.getMiddleName()#">
                                            <cfinput type="text" name="LastName" error_message="Please provide a last name for the employee you'd like to hire." tabindex="10" value="#Employee.getLastName()#">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>&nbsp;</td>
                                        <td>Preferred Name:</td>
                                        <td>
                                            <cfinput type="text" name="PreferredName" tabindex="20" tooltip="Would appear in the Address Book and be used to create their network account." value="#Employee.getPreferredName()#">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>&nbsp;</td>
                                        <td>Cost Code:</td>
                                        <td>
                                            <cfinput type="text" name="CostCode" tabindex="20"  value="#Employee.getCostCode()#" style="width:70%">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>&nbsp;</td>
                                        <td valign="top">Eligibility:</td>
                                        <td>                                        
                                            <input type="checkbox" name="Benefits" <cfif Employee.getBenefits() EQ 1>checked="true"</cfif> tabindex="50"> Benefits
                                            <BR />
                                            <input type="checkbox" name="Leave" <cfif Employee.getLeave() EQ 1>checked="true"</cfif> tabindex="60"> Leave
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>&nbsp;</td>
                                        <TD nowrap=nowrap valign='top'>Phones:</TD>
                                        <TD colspan=3>
                                            <fieldset style='border:inset'>
                                                <table>
                                                    <tr>
                                                        <td width =10>&nbsp;</td>
                                                        <td nowrap=nowrap>Home Phone:</td>
                                                        <td>
                                                            <cfinput type='text' name='HomePhone' maxlength='14' error_message='If provided, please confirm the home phone number with the employee.  The valid format is xxx-xxx-xxxx.' value="#Employee.getHomePhone()#" tabindex="22" >
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td width =10>&nbsp;</td>
                                                        <td nowrap=nowrap>Cell Phone:</td>
                                                        <td>
                                                            <cfinput type='text' name='CellPhone' maxlength='14' error_message='If provided, please confirm the cell phone number with the employee.  The valid format is xxx-xxx-xxxx.' value="#Employee.getCellPhone()#" tabindex="23" >
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td width =10>&nbsp;</td>
                                                        <td nowrap=nowrap>Work Phone:</td>
                                                        <td>
                                                            <cfinput type='text' name='WorkPhone' maxlength='14' error_message='If provided, please confirm the work phone number with the employee.  The valid format is xxx-xxx-xxxx.' value="#Employee.getWorkPhone()#" tabindex="24" >
                                                             x
                                                             <cfinput type='text' name='WorkPhoneExtention' maxlength=6 error_message='Work Phone Extension (if provided) must be numeric.' size=7 value="#Employee.getWorkPhoneExtention()#" tabindex="25" >
                                                        </td>
                                                    </tr>
                                                </table>
                                            </fieldset>
                                        </TD>
                                    </TR>
                                    <tr> 
                                        <td>&nbsp;</td>                   
                                        <td>Contact Email:</td>
                                        <td>
                                            <cfinput type="text" name="Email" maxlength="50" tabindex="28" tooltip="Confirm this email with the employee" error_message="Please provide the contact Email that appears on the employees application." style="width:98%" value="#Employee.getEmail()#" >
                                        </td>
                                    </tr>
                                    <tr> 
                                        <td>&nbsp;</td>       
                                    </tr>
                                    <tr>
                                        <td>&nbsp;</td>
                                        <td>Manager Comments:</td>
                                        <td>#Trim(StepAction.getNotes())#</td>
                                    </tr>
                                    <tr>
                                        <td>&nbsp;</td>
                                        <td>Position to Hire:</td>
                                        <td>#JobToHire#</td>
                                    </tr>
                                    <tr>
                                        <td width = "10">&nbsp;</td>
                                        <td>Kronos HR Position:</td>
                                        <td colspan=3>
                                            <cfselect name="PositionID" tabindex="10" >
                                                <option value="-1"> </option>
                                                <cfloop query="GetPositions">
                                                    <option value="#PositionIDNo#" <cfif PositionIDNo EQ Employee.getPositionID()>Selected = selected</cfif>>
                                                        #PositionCode# - #PositionCodeDescription#
                                                    </option>
                                                </cfloop>
                                            </cfselect>                           
                                        </td>
                                    </tr>
                                    <TR>
                                        <td width = "10">&nbsp;</td>
                                        <TD>Department:</TD>
                                        <TD colspan=3>
                                            <cfif Employee.getDepartmentID() EQ 0>
                                                <cfset Selected = GetSupDept.OrgCodeIDNo>
                                            <cfelse>
                                                <cfset Selected = Employee.getDepartmentID()>
                                            </cfif>
                                            <cfselect name="DepartmentID" tabindex="10" >
                                                <option value="-1"> </option>
                                                <cfloop query="GetDepts" >
                                                    <option value="#OrgCodeIDNo#" <cfif Selected EQ OrgCodeIDNo> selected=selected</cfif>>
                                                        #Org#
                                                    </option>
                                                </cfloop>
                                            </cfselect>
                                        </TD>
                                    </TR>
                                    <tr>
                                        <td width = "10">&nbsp;</td>
                                        <td>Supervisor:</td>
                                        <td>
                                            <cfselect name="SupervisorID" error_message="A supervisor must be chosen from the supervisor drop down list.">
                                                <option value="-1"> </option>
                                                <cfloop query="CurrentEmployees">
                                                    <cfset fullName = '#Trim(CurrentEmployees.LastName)#, #Trim(CurrentEmployees.FirstName)#'/>                            
                                                    <option value="#CurrentEmployees.RosettaID#">
                                                        #fullName# (#CurrentEmployees.Title#)                                                    
                                                    </option>
                                                </cfloop>
                                            </cfselect>
                                        </td>
                                    </TR>                                    
                                </table>     
                            </fieldset>
                        </td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                   </tr>
                    <tr> 
                        <td>
                            <fieldset>
                                <legend>2) Information obtained negotiating the position:</legend>
                                <table>
                                    <tr>
                                        <td width = "10">&nbsp;</td>
                                        <td colspan="4">
                                           <strong>Employee Position</strong>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width = "20" colspan="2">&nbsp;</td>       
                                        <td nowrap="nowrap">Employment Status:</td>
                                        <td>
                                            <cfselect name="EmployeeCodeID" query="GetEmpCodes" value="EmploymentCodeIDNo" display="EmploymentCode" tabindex="75"/> 
                                        </td>
                                        <td width = 20>&nbsp;</td> 
                                        <td valign="top" rowspan="5" nowrap="nowrap">
                                            Estimated Start Date: <BR />
                                            <cfinput type="hidden" name="EstStartDate" value="#DateFormat(now(), 'mm/dd/yyyy')#"/>
                                            <div id="EstStart_datepicker"></div>
                                        </td>
                                    </tr>
                                    <tr>  
                                        <td width = "20" colspan="2">&nbsp;</td>             
                                        <td>Salary/Hourly:</td>
                                        <td>
                                            <cfselect name="SalaryHourlyID" query ="GetSalaryHourly" value="ID" display="PersonCode" tabindex="30" selected="-10191"/>
                                        </td>
                                        <td width = 20>&nbsp;</td>     
                                    </tr>
                                    <tr>  
                                        <td width = "20" colspan="2">&nbsp;</td>             
                                        <td>Shift:</td>
                                        <td>
                                            <cfselect name="ShiftID" tabindex="35">
                                                <cfloop from="1" to="#ArrayLen(Shifts)#" index="i">
                                                    <option value="#Shifts[i].getShiftID()#" <cfif Employee.getShiftID() EQ Shifts[i].getShiftID()>selected='selected'</cfif>>#Shifts[i].getShiftType()#</option>
                                                </cfloop>
                                            </cfselect>
                                        </td>
                                        <td width = 20>&nbsp;</td>     
                                    </tr>
                                    <tr>  
                                        <td width = "20" colspan="2">&nbsp;</td>            
                                        <td nowrap="nowrap">FTE Hours/Week:</td>
                                        <td>
                                            <cfinput name="HoursPerWeek"  maxlength="2" size ="1" value="40" tabindex="40" error_message='Must be an valid number.' />
                                        </td>
                                        <td width =20>&nbsp;</td>       
                                    </tr>
                                    <tr>
                                        <td width = "20" colspan="2">&nbsp;</td>
                                        <td valign="top">Position Attributes:</td>
                                        <td valign="top" nowrap="nowrap">   
                                            <cfinput type="checkbox" name="Primary" checked="yes" tabindex="50"> Primary Position<BR />
                                            <cfinput type="checkbox" name="Exempt" tabindex="60"> Exempt<BR />
                                            <cfinput type="checkbox" name="FullTime" tabindex="65"> Full Time<BR />
                                            <cfinput type="checkbox" name="Seasonal" tabindex="70"> Seasonal    <BR />
                                            <cfinput type="radio" name="Daily" value="1" checked="yes">Daily<BR />
                                            <cfinput type="radio" name="Daily" value="0">Half Daily
                                        </td>
                                        <td width = 20>&nbsp;</td> 
                                    </tr>
                                    <tr>
                                        <td>&nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td width = "10">&nbsp;</td>
                                        <td colspan="5">
                                           <strong>Additional Job Info</strong>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width = "20" colspan="2">&nbsp;</td>
                                        <td colspan="4">
                                            Job Title:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <!---TODO: CHANGE THIS!!!!--->
                                            <cfinput type="text" name="JobTitle" readonly="yes" value="" class="readonly" style="width:65%"/>      
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width = "20" colspan="2">&nbsp;</td>
                                        <td colspan="2">
                                            <table cellpadding="0" cellspacing="0" width="100%">
                                                <tr>
                                                    <td>Job Code:</td>
                                                    <td width=95%>
                                                        <cfinput type="text" name="JobCode" readonly="yes" value="" class="readonly"  />                                                           
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Hours/Year:</td>
                                                    <td>
                                                        <cfinput type="text" name="HoursPerYear" readonly="yes" value="0" class="readonly"/>              
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Pay Grade:</td>
                                                    <td>
                                                        <cfinput type="text" name="PayGradeCode" readonly="yes" value="" class="readonly"/>         
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td nowrap="nowrap">Pay Grade Desc:&nbsp;&nbsp;</td>
                                                    <td>
                                                        <cfinput type="text" name="PayGradeCodeDescription" readonly="yes" value="" class="readonly"  style="width:99%"/>             
                                                    </td>
                                                </tr>                                                
                                            </table>                                            
                                        </td> 
                                        <td>&nbsp;</td> 
                                        <td> 
                                            <table cellpadding="0" cellspacing="0" width="100%">
                                                <tr>
                                                    <td nowrap="nowrap">SCF UDF 1:</td>
                                                    <td>
                                                        <cfinput type="text" name="SCF_UDF1" readonly="yes" value="" class="readonly"/>       
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td nowrap="nowrap">SCF UDF 2:</td>
                                                    <td>
                                                        <cfinput type="text" name="SCF_UDF2" readonly="yes" value="" class="readonly"/>             
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td nowrap="nowrap">SCF UDF 3:</td>
                                                    <td>
                                                        <cfinput type="text" name="SCF_UDF3" readonly="yes" value="" class="readonly"/>      
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td nowrap="nowrap">Worker's Comp Code:</td>
                                                    <td>
                                                        <cfinput type="text" name="WorkersCompCode" readonly="yes" value="0" class="readonly"/>    
                                                        <cfinput type="hidden" name="WorkersCompCodeID" />            
                                                    </td>
                                                </tr>                                          
                                            </table>                                            
                                        </td>
                                    </tr>                                    
                                    <tr>
                                        <td>&nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td width = "10">&nbsp;</td>
                                        <td colspan="5">
                                           <strong>Worker's Compensation</strong>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width = "20" colspan="2">&nbsp;</td>
                                        <td>State:&nbsp;&nbsp;Alaska</td>
                                    </tr>
                                    <tr>
                                        <td width = "20" colspan="2">&nbsp;</td>
                                        <td colspan="4">
                                            <cfselect name="WorkersCompID" tabindex="80">
                                                <option value="-10001">None</option>
                                                <cfloop query="GetWorkersCompInfo">
                                                    <option value="#WorkersCompensationIDNo#" <cfif WorkersCompensationIDNo EQ 0> selected=selected</cfif>>
                                                        #WorkersCompensationCode# #WorkersCompensationCodeDescription# (Rate=#WorkerCompRate#)
                                                    </option>
                                                </cfloop>
                                            </cfselect>
                                        </td>                                             
                                    </tr>
                                    <tr>
                                        <td>&nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td width = "10">&nbsp;</td>
                                        <td colspan="5">
                                           <strong>Pay Status</strong>
                                        </td>
                                    </tr>
                                      <tr>                                      
                                        <td width = "20" colspan="2">&nbsp;</td>
                                        <td>Compensation Type:</td>
                                        <td colspan="4">
                                            <cfselect name="CompTypeID" query="GetCompTypes" display="TypeCode" value="TypeCodeIDNo" tabindex="100" selected ="15"/>
                                        </td>
                                    </tr>
                                    <tr>                                        
                                        <td width = "20" colspan="2">&nbsp;</td>
                                        <td>Frequency:</td>
                                        <td colspan="4">
                                            <cfselect name="FrequencyID" tabindex="110">
                                                <cfloop query="GetFrequency">
                                                   <option value="#ID#:#AnnualizingFactor#" <cfif ID EQ -10103>selected=selected</cfif>>
                                                        #PayRateFrequencyCode# (Annualizing Factor: #AnnualizingFactor#)
                                                    </option>
                                                </cfloop>
                                            </cfselect> 
                                        </td>
                                    </tr>
                                    <tr>                                        
                                        <td width = "20" colspan="2">&nbsp;</td>
                                        <td>Pay Rate:</td>
                                        <td colspan="4">
                                            <cfinput type="text" name="PayRate" error_message="Please provide a numerical value for Pay Rate." tabindex="120">
                                        </td>
                                    </tr>
                                    <tr>                                        
                                        <td width = "20" colspan="2">&nbsp;</td>
                                        <td>Annual Salary:</td>
                                        <td colspan="4">
                                            <cfinput type="text" name="AnnaulSalary" tabindex="130" error_message="An Annual Salary is required">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>&nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td width = "10">&nbsp;</td>
                                        <td colspan="5">
                                           <strong>Comments</strong>
                                        </td>
                                    </tr>
                                    <tr>                                        
                                        <td width = "20" colspan="2">&nbsp;</td>
                                        <td colspan="5">
                                            <cftextarea name="Notes" rows="2" style="width:98%" tabindex="140" />
                                        </td>
                                    </tr>
                                </table>     
                            </fieldset>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="5" align="right" valign="middle" style="padding-top:5px;">
                            <cfinput type="hidden" name="EmpID" value="#Employee.getEmployeeID()#">
                            <cfinput type="hidden" name="FormAction" value="#FormAction#">
                            <cfinput type="hidden" name="FormDecline" value="#FormDecline#">
                            <cfinput type="hidden" name="StepID" value="#URL.StepID#">
                            <cfinput type="button" name="Submit" value="Next >>" tabindex="150" style="float:right">
                            <cfinput type="button" name="DeclineOffer" value="Offer Declined" tabindex="149">
                        </td>
                    </tr>
                </table>
            </cfform>            
        </div>
    
    </cfoutput>
    
</cffunction>